<route lang="jsonc" type="page">
{
  "layout": "default",
  "style": {
    "navigationBarTitleText": "库存入库记录"
  }
}
</route>

<script lang="ts" setup>
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'

const formData = ref<any>({

})

onLoad(async (options) => {
  if (options?.info) {
    try {
      console.log('info', options.info)
      // 1. 去掉字符串开头和结尾可能的多余引号
      const cleanedInfo = options.info.replace(/^"|"$/g, '')
      const pairs = cleanedInfo.split(',')
      // // 2. 遍历数组，解析键值
      const result = {}
      pairs.forEach((pair) => {
        const [key, value] = pair.split(':')
        result[key.trim()] = value === 'null' ? null : value // 处理 null 值
      })
      console.log(result)
      formData.value = result
      console.log(formData.value)
    }
    catch (error) {
      console.error('解析扫码信息失败', error)
    }
  }

  console.log('✅ 页面 onLoad 执行了', options)

  console.log('123')
})
</script>

<template>
  <view class="">
    库存入库记录
  </view>
</template>

<style lang="scss" scoped>
//
</style>
